<template>
  <div class="noticePage">
    <div class="header">
      <div class="title">
        <span class="icon sz_message_f"></span>
        <span class="txt">通知公告</span>
      </div>
      <div class="navList">
        <span
          :class="currentNav == index ? 'active' : ''"
          @click="changeNav(index)"
          v-for="(item, index) in bulList"
          :key="item.blockName + index"
          >{{ item.blockName }}</span
        >
      </div>
     <span class="more" @click="moreBul(bulList[currentNav].url)"
        >更多 <i class="sz_arrows_right"></i
      ></span>
    </div>
    <div class="content">
      <div class="bulList">
        <div class="newsItem" @click="toBulDetail(item)" v-for="(item, index) in bulList[currentNav].bulDataList.slice(0, 5)" :key="index">
          <span class="title" :title="item.title">{{ item.title }}</span>
          <span class="time">{{ item.createTime }}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      navList: [
        // {
        //   name: "全部",
        // },
        // {
        //   name: "上级下发",
        // },
        // {
        //   name: "本单位",
        // },
      ], //页签列表
      bulList: [
        // {
        //   des: "11111111111111111",
        //   link: "",
        //   date: "2022-12-12",
        // },
        // { des: "11111111111111111", link: "", date: "2022-12-12" },
        // { des: "11111111111111111", link: "", date: "2022-12-12" },
        // { des: "11111111111111111", link: "", date: "2022-12-12" },
        // { des: "11111111111111111", link: "", date: "2022-12-12" },
      ],
      currentNav: 0, //当前页签
    };
  },
  created() {},
  mounted() {
    this.getBulData();
  },
  methods: {
    // 获取公告数据
    getBulData(){
      this.axios({
        url:"/seeyon/rest/select/Bul",
        method:"post",
        headers: {
          "Content-Type": "application/json",
          "token":localStorage.getItem("restToken"),
        },
        data:{
          loginName: localStorage.getItem("loginName"),
          blockName:'会议规章制度',
        }
      }).then(res=>{
        console.log('获取公告数据',res)
        this.bulList = res.data.data
      })
    },
    // 切换页签
    changeNav(index) {
      this.currentNav = index;
    },
    // 更多新闻
    moreBul(url) {
      // window.open('/seeyon' + url, "_blank");
      this.axios({
        url: `/seeyon/oasso.do?method=redirect&loginName=${localStorage.getItem("loginName")}&url=${encodeURIComponent('/seeyon' + url)}`,
        method: "get",
        headers: {
          "Content-Type": "application/json",
        },
      }).then((res) => {
        console.log("点击新闻数据", res);
        window.open(res.data, "_blank");
      });
    },
    // 点击新闻
    toBulDetail(item){
      this.axios({
        url: `/seeyon/oasso.do?method=redirect&loginName=${localStorage.getItem("loginName")}&url=${encodeURIComponent('/seeyon' + item.url)}`,
        method: "get",
        headers: {
          "Content-Type": "application/json",
        },
      }).then((res) => {
        console.log("点击新闻数据", res);
        window.open(res.data, "_blank");
      });
    }
  },
};
</script>
<style lang="less" scoped>
.noticePage {
  width: 100%;
  height: 100%;
  .header {
    height: 50px;
    display: flex;
    align-items: center;
    position: relative;
    .title {
      font-weight: 600;
      font-size: 20px;
      line-height: 50px;
      .icon {
        margin-right: 5px;
        line-height: 50px;
        color: #1371ff;
        font-size: 20px;
        margin-right: 10px;
      }
    }
    .navList {
      margin-left: 20px;
      display: flex;
      height: 30px;
      span {
        font-size: 14px;
        padding: 0 15px;
        background-color: aliceblue;
        margin: 0 5px;
        border-radius: 15px;
        line-height: 30px;
        cursor: pointer;
      }
      .active {
        background-color: #2c85fb;
        color: #fff;
      }
    }
    .more {
      position: absolute;
      right: 0px;
      cursor: pointer;
      color: #a6a9ad;
      font-size: 14px;
      i{
        font-size: 12px;
      }
    }
  }
  .content {
    height: calc(100% - 50px);
    position: relative;
    display: flex;
    .imgList {
      height: 100%;
      width: 300px;
      overflow: hidden;
      margin-right: 10px;
      .imgItem {
        height: 100%;
        float: left;
        img {
          width: 100%;
        }
      }
    }
    .bulList {
      width: 100%;
      .newsItem {
        width: 100%;
        line-height: 42px;
        display: flex;
        .title {
          color: #121213;
          flex: 1;
          display: inline-block;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          cursor: pointer;
        }
        .time {
          color: #c7ccd1;
          width: 120px;
          display: inline-block;
          text-align: right;
          cursor: pointer;
        }
      }
    }
  }
}
</style>